package com.example.tests;

import java.util.Random;
import org.testng.annotations.Test;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.*;

import com.example.utils.SortedListOf;

public class ContactDeletion extends AddressbookTestBase{

	@Test(dataProvider = "randomValidContactGenerator")
	public void deleteSomeContact(ContactData contactInput){
		//save old state
		SortedListOf<ContactData> oldList = app.getContactHelper().getContacts();
		//save old index state
		SortedListOf<Integer> idList = app.getContactHelper().getContactId();
		//prereq - fullfill list
		Random rnd = new Random();
		//int listSize = idList.size();
		int index = rnd.nextInt(idList.size()-1);
		int element = idList.get(index);	
		//actions
		app.getContactHelper().deletionContact(element);		
		//save new state
		SortedListOf<ContactData> newList = app.getContactHelper().getContacts();		
		//compare states		
		assertThat(newList, equalTo(oldList.without(element)));
	}
	
}
